"use strict";
cc._RF.push(module, '4ce06fZU6xGhqNTmPJeFnsF', 'WechatUtils');
// script/standar/utils/js/WechatUtils.js

"use strict";

module.exports = {
  previewImage: function previewImage(url) {
    if (window.wx != undefined) {
      //var Imgurl = 'http://img3.douban.com/view/photo/photo/public/p2152117150.jpg';
      var Imgurl = url;
      wx.previewImage({
        urls: [Imgurl],
        success: function success(res) {
          console.log(res);
        },
        fail: function fail(res) {
          return;
        }
      });
    }
  },
  ready: function ready(callback) {
    if (window.wx != undefined) {
      wx.ready(function () {
        callback();
      });
    }
  },
  shareConfig: function shareConfig(callback, headline, galleryid, bg_style) {
    if (callback) callback(); // var data = encodeURIComponent(window.location.href.split('#')[0]);
    // var t_url = "http://mp.qdmedia.cc/api/Wechat/signPackage?data=" + data;
    //alert(getSignPackage.appId);

    console.log(getSignPackage);
    console.log(getSignPackage.appId);
    wx.config({
      debug: false,
      appId: getSignPackage.appId,
      timestamp: getSignPackage.timestamp,
      nonceStr: getSignPackage.nonceStr,
      signature: getSignPackage.signature,
      jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'chooseImage', 'getLocalImgData', 'uploadImage', 'downloadImage']
    });
    wx.ready(function () {
      //cc.director.GlobalEvent.sendEvent("wxReady", "");
      var shareData = {
        title: headline,
        desc: '快来领取你的专属美术馆',
        link: "http://screen.qdmedia.cc/artgallery?gallery_id=" + galleryid + "&bg_style=" + bg_style,
        imgUrl: 'http://h5files.oss-cn-hangzhou.aliyuncs.com/artGallery/test/Icon.jpg',
        success: function success(res) {
          alert("分享成功"); //cc.director.GlobalEvent.sendEvent("shareSuccess", "");
        }
      }; //alert(window.location.href);

      wx.onMenuShareAppMessage(shareData);
      wx.onMenuShareTimeline(shareData);
    });
    /* HttpHelper.Get(t_url, function (response) {
             var r = JSON.parse(response);
           var data = r.data;
           //console.log("data:" + data.appId);
           wx.config({
             debug: false,
             appId: data.appId,
             timestamp: data.timestamp,
             nonceStr: data.nonceStr,
             signature: data.signature,
             jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'chooseImage', 'getLocalImgData', 'uploadImage', 'downloadImage']
         });
             wx.ready(function () {
               //cc.director.GlobalEvent.sendEvent("wxReady", "");
               var shareData = {
                 title: headline,
                 desc: '快来领取你的专属美术馆',
                 link: "http://screen.qdmedia.cc/artgallery?gallery_id=" + galleryid,
                 imgUrl: 'http://h5files.oss-cn-hangzhou.aliyuncs.com/artGallery/test/Icon.jpg',
                 success: function (res) {
                       alert("分享成功");
                     //cc.director.GlobalEvent.sendEvent("shareSuccess", "");
                 }
             };
             alert(window.location.href);
             wx.onMenuShareAppMessage(shareData);
             wx.onMenuShareTimeline(shareData);
         });
     })*/
  }
};

cc._RF.pop();